<?php
abstract class BaseValidate {
	var $item = null;
	var $params = null;
	var $langs = null;
	var $error = null;
	var $mutil_lan = false;
	
	public function validate($val){
		if($this->mutil_lan!==false){
			//多语言
			foreach($this->langs as $lang){
				$result = $this->v($val[$lang]);
				if($result === false){
					return false;
				}
			}
		}else{
			//单语言
			return $this->v($val);
		}
		return true;
	}
	
	/**
	 * 获取错误原因
	 */
	public function get_error(){
		return $this->error;
	}
	
	protected function get_item_name($lang = null){
		if($lang!==null){
			if(isset($this->item[$lang]['name'])){
				return $this->item[$lang]['name'];
			}
		}
		
		$lang = LANGUAGE;
		if(isset($this->item[$lang]['name'])){
			return $this->item[$lang]['name'];
		}
		return $this->item['name'];
	}
	
	public abstract function v($val, $lang = null);
}

?>